<template>
  <el-form label-width="120px">
    <el-form-item label="ID："> {{ loadUserDetail.id }}</el-form-item>
    <el-form-item label="名称：">{{ loadUserDetail.loginAct }} </el-form-item>
    <el-form-item label="姓名：">{{ loadUserDetail.name }} </el-form-item>
    <el-form-item label="手机：">{{ loadUserDetail.phone }} </el-form-item>
    <el-form-item label="邮箱：">{{ loadUserDetail.email }} </el-form-item>
    <el-form-item label="账号未过期："
      >{{ loadUserDetail.accountNoExpired == 1 ? "是" : "否" }}
    </el-form-item>
    <el-form-item label="密码未过期："
      >{{ loadUserDetail.credentialsNoExpired == 1 ? "是" : "否" }}
    </el-form-item>
    <el-form-item label="账号未锁定："
      >{{ loadUserDetail.accountNoLocked == 1 ? "是" : "否" }}
    </el-form-item>
    <el-form-item label="账号是否启用："
      >{{ loadUserDetail.accountEnabled == 1 ? "是" : "否" }}
    </el-form-item>
    <el-form-item label="创键时间："
      >{{ loadUserDetail.createTime }}
    </el-form-item>
    <el-form-item label="创键人："
      >{{ loadUserDetail.createByDO.name }}
    </el-form-item>
    <el-form-item label="编辑时间："
      >{{ loadUserDetail.editTime }}
    </el-form-item>
    <el-form-item label="编辑人："
      >{{ loadUserDetail.editByDO.name }}
    </el-form-item>
    <el-form-item label="最近登录时间："
      >{{ loadUserDetail.lastLoginTime }}
    </el-form-item>
    <el-form-item
      ><el-button type="success" @click="goBack">返回</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
import { doGet } from "@/http/httpRequest";
import { onMounted, reactive, ref } from "vue";
import { useRoute } from "vue-router";
import router from "@/router/router";
export default {
  setup() {
    let loadUserDetail = reactive({
      createByDO: {},
      editByDO: {},
    });
    const route = useRoute();
    const userId = route.params.id;
    onMounted(() => {
      loadUserDetails();
    });
    function loadUserDetails() {
      doGet("/api/user/" + userId, {}).then((resp) => {
        if (resp.data.code === 200) {
          Object.assign(loadUserDetail, resp.data.data);
          if (!loadUserDetail.createByDO) {
            loadUserDetail.createByDO = {};
          }
          if (!loadUserDetail.editByDO) {
            loadUserDetail.editByDO = {};
          }
        }
      });
    }
    function goBack() {
      router.go(-1);
    }
    return { loadUserDetail, goBack };
  },
};
</script>